package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username
     * @return
     */
    Employee getByUsername(String username);

    /**
     * 添加员工
     *
     * @param employee
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Employee employee);

    /**
     * 分页查询员工数据
     *
     * @param employeePageQueryDTO
     * @return
     */
    List<Employee> page(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 启用禁用员工账号
     *
     * @param employee
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateStatus(Employee employee);

    /**
     * 根据id查询员工
     *
     * @param id
     * @return
     */
    Employee getEmployeeById(Long id);

    /**
     * 根据id删除员工信息
     *
     * @param id
     */
    void delete(Long id);

    /**
     * 获取员工总数
     *
     * @return
     */
    @Select("select count(*) from employee")
    Integer getAllEmployee();

    /**
     * 获取新增员工
     *
     * @param begin
     * @param end
     * @return
     */
    @Select("select count(*) from employee where create_time >= #{begin} and create_time <= #{end}")
    Integer getAddEmployee(String begin, String end);

    /**
     * 获取男生数量
     *
     * @return
     */
    @Select("select count(*) from employee where sex = 1")
    Integer getBoyNumber();

    /**
     * 获取女生数量
     *
     * @return
     */
    @Select("select count(*) from employee where sex = 0")
    Integer getGirlNumber();

    /**
     * 获取启用员工数量
     *
     * @param enable
     * @return
     */
    @Select("select count(*) from employee where status = #{enable}")
    Integer getEnableEmployee(Integer enable);
}
